<template>
	<view style="padding: 30rox;">
		<button @click="onSetTimeOut()">单次计时器</button>
		<button @click="onSetTimeOut('aa',666)" plain="true">启动传参计时器</button>
		<button @click="onClearTimeOut()">取消计时器</button>
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name:'aaa',
				timer1:null,
				
			}
		},
		methods: {
			onSetTimeOut(){
				console.log("onSetTimeOut");
				// 延时3s的定时器
				this.timer1 = setTimeout(()=>{
					console.log("onSetTimeOut() callback");
					
					console.log("onSetTimeOut() callback end");
				},3000);
			},
			// onSetTimeOut(username,pwd){
			// 	console.log("onSetTimeOut()",username,pwd);
			// 	// ()=>{ }
			// 	setTimeout((x,y)=>{
			// 		console.log("-----callback",x,y);
			// 	},2000,username,pwd)
			// },
			onClearTimeOut(){
				console.error("onClearTimeOut() 取消计时器");
				clearTimeout(this.timer1)
			}
		}
	}
</script>

<style>
	button{
		margin: 20rpx;
	}

</style>
